/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.io.dot;

import java.util.HashMap;
import java.util.Map;

import org.jgrapht.ext.VertexNameProvider;

public class DOTColorVertexNameProvider<E> implements VertexNameProvider<E>{

	private static String defaultColor = "black";
	private Map<E, String> colors;
	private Map<E, String> other;
	private Map<E, String> alternateName;
	
	public DOTColorVertexNameProvider (Map<E, String> couleurs, Map<E, String> other)
	{
		colors = couleurs;
		this.other = other;
		this.alternateName = new HashMap<E,String>();
	}

	
	public DOTColorVertexNameProvider (Map<E, String> couleurs, Map<E, String> other, Map<E, String> alternateName)
	{
		colors = couleurs;
		this.other = other;
		this.alternateName = alternateName;
	}
	
	@Override
	public String getVertexName(E vertex) {
		String result = new String();
		if (other.containsKey(vertex))
		{
			result = result + ","+ other.get(vertex);
		}
		if (colors.containsKey(vertex))
		{
			result = result +",color=" + colors.get(vertex);
		}
		else
		{
			result = result + ",color=" + defaultColor;
		}
		if(alternateName.containsKey(vertex))
		{
			return "\"" +alternateName.get(vertex) + "\"" +result ;
		}
		else
		{
			return "\"" +vertex.toString() + "\"" + result;
		}
	}
	
	

}
